#include "MeasureWorkpiece.h"

MeasureWorkpiece::MeasureWorkpiece(QObject *parent) : QObject(parent)/*,
                                        m_threadStopFlag(false)*/
{
//    m_workpieceBuff.SetSize(2);
//    if(!m_initThreadFinished_) {
//        InitThread();
//    }
}

MeasureWorkpiece::~MeasureWorkpiece()
{
    //    ExitThread();
}

void MeasureWorkpiece::SetWorkpieceInfo(const string &modeName, const string &workpieceType)
{

}

//bool Workpiece::SetTemplatePath(const std::string &path)
//{
//    return false;
//}

//bool Workpiece::SetStandardVal(const std::map<string, float> &standardValMap)
//{
//    return false;
//}

//bool Workpiece::SetTemplatePath(const std::string &path)
//{
//    return false;
//}

//void Workpiece::CacheData(const Mat &image, const QPoint &datumOffset, int workpieceId, int pictureId, int channelId, int fixtureId)
//{

//}

//void Workpiece::ProcessData()
//{

//}

//bool Workpiece::GetDatumPixelDistance(const QImage &img, int fixtureId, QMap<QString, float> &pixelDistance)
//{
//    return false;
//}

//void Workpiece::InitThread()
//{
//    for(int i = 0; i < 3; i++) {
//        qDebug() << "start thread";
//        m_threadPool.emplace_back(std::thread(&Workpiece::ProcessData,
//                                              this));
//    }
//    qDebug() << "start thread success";
//    m_initThreadFinished_ = true;
//}

//void Workpiece::ExitThread()
//{
//    if(m_initThreadFinished_) {
//        if(!m_threadStopFlag) {
//            m_threadStopFlag = true;
//        }
//        qDebug() << "start to exit thread";

////        int loopCount = 0;
////        while(!m_workpieceBuff.Empty() && loopCount < 3) {
////            sleep(1);
////            loopCount++;
////        }

////         调用该语句释放条件变量的等待条件
////        m_workpieceBuff.Exit();

//        for(size_t i = 0; i < m_threadPool.size(); ++i) {
//            m_threadPool[i].join();
//        }

//        qDebug() << "measurement thread exit safely!";
//    }
//}
